package com.platform.modules.sys.controller;

import com.platform.common.utils.ExcelExport;
import com.platform.modules.sys.entity.SysUserEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * 测试导出Excel
 */
@RequestMapping("/test")
@Controller
public class ExcelExportTestController {
    @RequestMapping("/export")
    public void exportInventoryResult(HttpServletResponse response) {
        List<SysUserEntity> users = new ArrayList<>();
        SysUserEntity sysUserEntity = new SysUserEntity();
        sysUserEntity.setUserName("10001");
        sysUserEntity.setRealName("张三");
        sysUserEntity.setOrgNo("计算机");
        sysUserEntity.setPosition("软件1班");
        users.add(sysUserEntity);
        try {
            ExcelExport excelExport = new ExcelExport();
            excelExport.writeBigExcel(response, "保有量导出数据", new String[]{"userName", "realName", "orgNo", "position"}
                    , new String[]{"学号", "姓名", "专业", "班级"}
                    , new int[]{30, 30, 30, 30}, users);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
